package com.onlinetest.qxy;

public class Poker implements Comparable<Poker> {
// 花色 红桃 黑桃 草花 方片
// 牌面 A~K

	int huase;// 0 1 2 3
	int num;// 0~12

	public int getHuase() {
		return huase;
	}

	public void setHuase(int huase) {
		this.huase = huase;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public Poker(int huase, int num) {
		super();
		this.huase = huase;
		this.num = num;
	}

	public Poker() {
		super();
		// TODO Auto-generated constructor stub
	}

	@Override
	public String toString() {
		String result;
		String[] huaseArr = { "♥", "♠", "♦", "♣" };
		String[] numArr = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
		return huaseArr[huase] + numArr[num];
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + huase;
		result = prime * result + num;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Poker other = (Poker) obj;
		if (huase != other.huase)
			return false;
		if (num != other.num)
			return false;
		return true;
	}

	@Override
	public int compareTo(Poker o) {
		// 传入另外一张牌，判断谁在前，谁在后
		// this.huase
		// this.num

		// o.hause
		// o.num

		// 先比较花色
		if (this.huase > o.huase) {
			return 1;
		} else if (this.huase < o.huase) {
			return -1;
		} else {
			// 花色相同，再比较数字
			if (this.num > o.num) {
				return 1;
			} else if (this.num < o.num) {
				return -1;
			} else {
				// 花色相同 数字也相同
				return 0;
			}
		}

	}

}